 /**
 * @file ProtocolMessageQueue.cs
 * @author Zane Mayo
 * @date 19/5/2009
 */

using System;
using System.Collections.Generic;

namespace MxitAPI {
	
	
	public class ProtocolMessageSendQueue {
		
		private static log4net.ILog log = log4net.LogManager.GetLogger( System.Reflection.MethodBase.GetCurrentMethod().DeclaringType );
		
		private static ProtocolMessageSendQueue instance;
		
		private Queue<ProtocolMessage> queue;
		
		protected ProtocolMessageSendQueue() {
			queue = new Queue<ProtocolMessage>();
		}
		
		public static ProtocolMessageSendQueue Instance {
			get { 
				if( instance == null)
					instance = new ProtocolMessageSendQueue();
				return instance;
			}
		}
		
		public bool IsEmpty {
			get { return queue.Count == 0; }
		}
		
		public void AddProtocolMessage( ProtocolMessage protocolMessage ) {
			queue.Enqueue( protocolMessage );
		}
		
		public ProtocolMessage GetNextProtocolMessage(){
			if ( IsEmpty ) 
				throw new MxitTransceiverException( "Send protocol message queue empty." );
			return queue.Dequeue();
		}
		
		
	}
}
